package TestHelper;

use Test::More;
use File::Copy;

use Exporter 'import';

@EXPORT = qw(isSame);

sub isSame {
	my ($f1, $f2) = @_;

	ok(-e $f1);
	open (OUT,  "<$f1");
	my @lines1 = <OUT>;
	close (OUT);
	
	if (!-e $f2) {
		copy("$f1", "$f2") or die "Copy failed: $!";
	}
	

	ok(-e $f2);
	open (REAL, "<$f2");
	my @lines2 = <REAL>;
	close (REAL);
	
	@lines1 = grep { $_ =~ s/^.*Generator version:.*$//; $_} @lines1;
	@lines2 = grep { $_ =~ s/^.*Generator version:.*$//; $_} @lines2;
	
	ok(@lines1 != 0);
	ok(@lines2 != 0);
	
	is_deeply(\@lines1, \@lines2, "Compare generated '$f1' and real '$f2'");
}


1;